package net.luculent.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONObject;

import net.luculent.service.IndexService;

@Controller
@RequestMapping("/web")
public class IndexController {
private static final Logger logger =  LoggerFactory.getLogger(IndexController.class);
	
	@Autowired()
	private IndexService indexService;

	@RequestMapping("index")
	public String index(ModelMap map){
		JSONObject obj = indexService.getHotKey();
		
		if(obj != null){
			logger.info(obj.toString());
			map.put("result", obj.toString());
		}else{
			logger.info("返回数据不是标准json格式");
		}
		
		map.put("title", "LWFirstStudy 首页");
		return "index";
	}
}
